<?php
/**
 * Banner 控制层
 */
namespace api\controllers;

use api\components\ApiController;
use yii\web\Response;
use Yii;


class SessionController extends ApiController
{

    /**
     * session 写入redis
     */
    public function actionSession()
    {
        $arr = [
            'name' => 'test',
            'age' => '23',
            'sex' => '男'
        ];
        //$arrStr = serialize($arr);
        //直接将session写入redis
          //Yii::$app->session->set('test1555', '12566');
          //Yii::$app->session->writeSession('zcy123','hello world cy');
          $res=Yii::$app->session->readSession('zcy123');
          var_dump($res);die;
        /*//读取
        Yii::$app->session->readSession('test');
        //删除
        Yii::$app->session->destorySession('test');*/
        Yii::$app->response->format = Response::FORMAT_JSON;
        return ['data' => '111'];

    }


}
?>